package n2777;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	
	static class Node{
		int left,right;
		int color;
	}
	static int L,T,O;
	static int MAX=100001;
	static Node[] arr=new Node[MAX*4];
	static{
		for(int i=0;i<arr.length;i++)arr[i]=new Node();
	}
	static void build(int index,int left,int right)
	{
		arr[index].left=left;
		arr[index].right=right;
		arr[index].color=1;
		if(left==right)return;
		int mid=(left+right)>>1;
		build(index*2,left,mid);
		build(index*2+1,mid+1,right);
	}
	
	static void insert(int index,int left,int right,int color)
	{
		if(arr[index].left>right||arr[index].right<left)return;
		if(arr[index].left>=left&&arr[index].right<=right)
		{
			//完全覆盖
			arr[index].color=color;
			return;
		}
		//部分覆盖
		if(arr[index].color>0&&arr[index].color!=color)
		{
			arr[index*2].color=arr[index].color;
			arr[index*2+1].color=arr[index].color;
			arr[index].color=-1;
		}
		insert(index*2,left,right,color);
		insert(index*2+1,left,right,color);
	}
	
	static int sum=0;
	static int clr[]=new int[31];
	static void calc(int index,int left,int right)
	{
//		System.out.println("calc:"+index+" "+left+" "+right+" "+arr[index].color);
		if(arr[index].color>0)
		{
			if(clr[arr[index].color]==0)
			{
				sum++;
				clr[arr[index].color]=1;
			}
			return;
		}
		if(arr[index].left==arr[index].right)return;
		int mid=(arr[index].left+arr[index].right)>>1;
		if(left>mid)
		{
			calc(index*2+1,left,right);
		}else if(right<=mid)
		{
			calc(index*2,left,right);
		}else{
			calc(index*2,left,mid);
			calc(index*2+1,mid+1,right);
		}
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st=new StringTokenizer(bf.readLine());
		L=Integer.parseInt(st.nextToken());
		T=Integer.parseInt(st.nextToken());
		O=Integer.parseInt(st.nextToken());
		build(1, 1, L);
		for(int i=0;i<O;i++)
		{
			st=new StringTokenizer(bf.readLine());
			String op=st.nextToken();
			if(op.equals("C"))
			{
				int left=Integer.parseInt(st.nextToken());
				int right=Integer.parseInt(st.nextToken());
				int color=Integer.parseInt(st.nextToken());
				if(left>right){
					int tmp=left;
					left=right;
					right=tmp;
				}
				insert(1, left, right, color);
			}else if(op.equals("P"))
			{
				int left=Integer.parseInt(st.nextToken());
				int right=Integer.parseInt(st.nextToken());
				if(left>right){
					int tmp=left;
					left=right;
					right=tmp;
				}
				Arrays.fill(clr, 0);
				sum=0;
				calc(1, left, right);
				System.out.println(sum);
			}
					
		}
		
	}

}
